package net.slteam.base;

import net.slteam.base.util.BeanUtil;

import java.io.Serializable;

/**
 * ClassName: IBaseBean
 * Description:
 * date: 3/9/22 9:24 AM
 *
 * @author calm
 * @since JDK 1.8
 */
public interface IBaseBean extends Serializable {
    
    default <T> T toDTO(Class<T> cls) {
        try {
            T object = cls.newInstance();
            toDTO(object);
            return object;
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }

    default Object toDTO(Object object) {
        BeanUtil.copyNotNullProperties(this, object);
        return object;
    }

    default <T> T toPO(Class<T> cls) {
        return toDTO(cls);
    }
}
